package top.jinlijun.heytea.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import top.jinlijun.heytea.entities.Attribute;
import top.jinlijun.heytea.entities.Commodity;
import top.jinlijun.heytea.entities.CommodityType;
import top.jinlijun.heytea.mapper.CommodityMapper;
import top.jinlijun.heytea.service.ICommodityService;

import java.util.List;

@Service
//@Transactional
public class CommodityServiceImpl implements ICommodityService {

    @Autowired
    CommodityMapper commodityMapper;

    public List<Commodity> getCommodities() {
        List<Commodity> commodities = commodityMapper.getCommodities();
        return commodities;
    }

    @Override
    public List<Attribute> getAttributes() {
        List<Attribute> attributes = commodityMapper.getAttributes();
        return attributes;
    }

    @Override
    public void insertCommodity(Commodity commodity) {
        commodityMapper.insertCommodity(commodity);
    }

    @Override
    public List<CommodityType> getAllCommodityTypes() {
        return commodityMapper.getAllCommodityTypes();
    }

    @Override
    public void addCommodityType(CommodityType commodityType) {
        commodityMapper.addCommodityType(commodityType);
    }

    @Override
    public void deleteCommodityType(CommodityType commodityType) {
        commodityMapper.deleteCommodityType(commodityType);
    }

    @Override
    public void updateCommodityType(CommodityType commodityType) {
        commodityMapper.updateCommodityType(commodityType);
    }

    @Override
    public List<Attribute> getAttributeById(Integer id) {
        List<Attribute> attributes = commodityMapper.getAttributeById(id);
        return attributes;
    }
}
